package top.hcode.hoj.pojo.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.nutz.lang.Strings;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author orangej
 * @since 2025/1/21
 */
@ApiModel("登录信息")
@Data
public class OrgUserLoginDTO {
    @ApiModelProperty(value = "用户类型，0 学生；1 教师")
    @NotNull(message = "用户类型不能为空")
    private Integer userType;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "手机号，教师登录可以使用手机号")
    private String mobile;

    @ApiModelProperty(value = "真实姓名")
    @NotBlank(message = "姓名不能为空")
    private String realName;

    @AssertTrue(message = "用户名不能为空")
    public boolean isValidUsername() {
        return Strings.isNotBlank(username) || Strings.isNotBlank(mobile);
    }
}
